#include "Tree.h"
#include "World.h"

Tree::Tree(World &i_world, ETreeType i_type)
  :m_world(i_world)
  {
  switch (i_type)
    {
    case TT_DEFAULT_TREE:
      m_type = "DEFAULT_TREE_0";
      m_name = m_type + " " + std::to_string(m_id_cnt++);
      m_state = 0;
      break;
    default:
      break;
    }

  m_world.AddRenderable(this);
  m_world.AddAnimated(this);
  }

void Tree::NextFrame()
  {
  switch (m_state)
    {
    case 0:
      m_state = 1;
      m_type = "DEFAULT_TREE_0";
      break;
    case 1:
      m_state = 2;
      m_type = "DEFAULT_TREE_1";
      break;
    case 2:
      m_state = 3;
      m_type = "DEFAULT_TREE_1";
      break;
    case 3:
      m_state = 4;
      m_type = "DEFAULT_TREE_2";
      break;
    case 4:
      m_state = 5;
      m_type = "DEFAULT_TREE_2";
      break;
    case 5:
      m_state = 6;
      m_type = "DEFAULT_TREE_1";
      break;
    case 6:
      m_state = 7;
      m_type = "DEFAULT_TREE_1";
      break;
    case 7:
      m_state = 0;
      m_type = "DEFAULT_TREE_0";
      break;
    default:
      break;
    }
  }

std::string Tree::GetName() const
	{
	return WorldObject::GetName();
  }

Tree::~Tree()
  {
  m_world.RemoveRenderable(this);
  m_world.RemoveAnimated(this);
  }
